

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
    <style>
    /* base */
    html,
    body,
    .container {
      width: 100%;
      height: 100%;
    }

    a,
    a:link,
    a:visited {
      text-decoration: none;
      color: inherit;
    }

    ul {
      list-style: none;
    }

    *,
    ::before,
    ::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    *:focus {
      outline: 0;
    }

    .container {
      display: flex;
      padding-top: 20px;
    }

    /* Nav */
    .container .doc-nav {
      position: fixed;
      height: 100%;
      margin: 0 30px 0 40px;
      width: 280px;
    }

    .doc-nav .nav-header {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      background-color: rgb(240, 241, 242);
      height: 40px;
      padding: 16px;
      font-size: 18px;
      font-weight: 500;
      color: rgb(62, 64, 66);
      cursor: pointer;
    }

    .doc-nav .nav-content {
      height: calc(100% - 40px);
      overflow-y: auto;
      color: rgb(32, 34, 36);
    }

    .doc-nav .nav-content .nav-list,
    .doc-nav .nav-content .nav-sub-list {
      line-height: 1.5rem;
    }

    .doc-nav .nav-content .nav-label {
      display: inline-block;
      position: relative;
      padding: 2px 0 2px 20px;
      margin-bottom: 4px;
    }

    .doc-nav .nav-content .nav-sub-label {
      position: relative;
      padding: 2px 0 2px 40px;
      font-size: 14px;
    }

    .doc-nav .nav-content .nav-sub-label:hover {
      text-decoration: underline;
    }

    .doc-nav .nav-content .nav-list .nav-label.group::before {
      border-bottom: 0.25rem solid transparent;
      border-left: 0.25rem solid #6e7072;
      border-right: 0;
      border-top: 0.25rem solid transparent;
      content: '';
      display: block;
      height: 0;
      left: 0.5rem;
      position: absolute;
      top: 0.625rem;
      transition: transform 0.1s linear;
      width: 0;
    }

    .doc-nav .nav-content .nav-list .nav-label.group.active::before {
      transform: rotate(90deg);
    }

    /* doc content */
    .container .doc-content {
      position: fixed;
      height: 100%;
      width: calc(100% - 80px - 40px - 30px - 240px);
      right: 0%;
      overflow-y: auto;
    }

    .doc-title {
      border-bottom: 1px solid #dcdee0;
      font-size: 22px;
      margin: 8px 0 0;
      padding-bottom: 16px;
    }

    .doc-content h3 {
      font-size: 24px;
      font-weight: 600;
      margin: 24px 0;
    }

    .doc-content h4 {
      font-size: 22px;
      font-weight: 500;
      margin: 30px 0 8px;
    }

    .doc-content h4 span {
      color: #007d9c;
    }

    .doc-content .doc-declare {
      background-color: #fafafa;
      border-radius: 5px;
      border: 1px solid #ccc;
      font-size: 14px;
      overflow-x: auto;
      padding: 10px;
      tab-size: 4;
      line-height: 20px;
    }

    .doc-content .doc-comment {
      font-size: 16px;
      margin: 16px 0;
      line-height: 24px;
      word-break: break-word;
    }
  </style>

</head>
<body>
  <div class="container">
    <div class="doc-nav">
      <a href="#Documentation" class="nav-header">Documentation</a>
      <nav class="nav-content">
        <ul class="nav-list">
          <li>
            <a href="#includes" class="nav-label">Includes</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#config.h" class="nav-sub-label">config.h</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_CONFIG_FILE" class="nav-sub-label">MBEDTLS_CONFIG_FILE</a>
              </li>
      

              <li>
                <a href="#cipher.h" class="nav-sub-label">cipher.h</a>
              </li>
      

              <li>
                <a href="#stdint.h" class="nav-sub-label">stdint.h</a>
              </li>
      

              <li>
                <a href="#gcm_alt.h" class="nav-sub-label">gcm_alt.h</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#macros" class="nav-label">Macros</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#MBEDTLS_GCM_H" class="nav-sub-label">MBEDTLS_GCM_H</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_GCM_ENCRYPT" class="nav-sub-label">MBEDTLS_GCM_ENCRYPT</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_GCM_DECRYPT" class="nav-sub-label">MBEDTLS_GCM_DECRYPT</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_ERR_GCM_AUTH_FAILED" class="nav-sub-label">MBEDTLS_ERR_GCM_AUTH_FAILED</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_ERR_GCM_HW_ACCEL_FAILED" class="nav-sub-label">MBEDTLS_ERR_GCM_HW_ACCEL_FAILED</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_ERR_GCM_BAD_INPUT" class="nav-sub-label">MBEDTLS_ERR_GCM_BAD_INPUT</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#functions" class="nav-label">Functions</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#mbedtls_gcm_init" class="nav-sub-label">mbedtls_gcm_init</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_setkey" class="nav-sub-label">mbedtls_gcm_setkey</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_crypt_and_tag" class="nav-sub-label">mbedtls_gcm_crypt_and_tag</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_auth_decrypt" class="nav-sub-label">mbedtls_gcm_auth_decrypt</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_starts" class="nav-sub-label">mbedtls_gcm_starts</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_update" class="nav-sub-label">mbedtls_gcm_update</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_finish" class="nav-sub-label">mbedtls_gcm_finish</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_free" class="nav-sub-label">mbedtls_gcm_free</a>
              </li>
      

              <li>
                <a href="#mbedtls_gcm_self_test" class="nav-sub-label">mbedtls_gcm_self_test</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#vars" class="nav-label">Vars</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#consts" class="nav-label">Consts</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#types" class="nav-label">Types</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#typedefs" class="nav-label">Typedefs</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#
mbedtls_gcm_context;
" class="nav-sub-label">
mbedtls_gcm_context;
</a>
              </li>
      
            </ul>
            
          </li>
        </ul>
      </nav>
    </div>
    <div class="doc-content">
      <h2 id="Documentation" class="doc-title">Documentation</h2>
      <h3 id="includes">Includes</h3>
      

      <h4 id="config.h"><span>config.h</span></h4>
      <pre class="doc-declare"><code>#include "config.h"
</code></pre>
      <pre class="doc-comment">#include "config.h"
</pre>

      <h4 id="MBEDTLS_CONFIG_FILE"><span>MBEDTLS_CONFIG_FILE</span></h4>
      <pre class="doc-declare"><code>#include MBEDTLS_CONFIG_FILE
</code></pre>
      <pre class="doc-comment">#include MBEDTLS_CONFIG_FILE
</pre>

      <h4 id="cipher.h"><span>cipher.h</span></h4>
      <pre class="doc-declare"><code>#include "cipher.h"
</code></pre>
      <pre class="doc-comment">#include "cipher.h"
</pre>

      <h4 id="stdint.h"><span>stdint.h</span></h4>
      <pre class="doc-declare"><code>#include &lt;stdint.h&gt;
</code></pre>
      <pre class="doc-comment">#include <stdint.h>
</pre>

      <h4 id="gcm_alt.h"><span>gcm_alt.h</span></h4>
      <pre class="doc-declare"><code>#include "gcm_alt.h"
</code></pre>
      <pre class="doc-comment">#include "gcm_alt.h"
</pre>
      <h3 id="macros">Macros</h3>
      

      <h4 id="MBEDTLS_GCM_H">Marco <span>MBEDTLS_GCM_H</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_GCM_H
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MBEDTLS_GCM_ENCRYPT">Marco <span>MBEDTLS_GCM_ENCRYPT</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_GCM_ENCRYPT    1
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MBEDTLS_GCM_DECRYPT">Marco <span>MBEDTLS_GCM_DECRYPT</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_GCM_DECRYPT    0
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MBEDTLS_ERR_GCM_AUTH_FAILED">Marco <span>MBEDTLS_ERR_GCM_AUTH_FAILED</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_ERR_GCM_AUTH_FAILED                      -18 /**< Authenticated decryption failed. */
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MBEDTLS_ERR_GCM_HW_ACCEL_FAILED">Marco <span>MBEDTLS_ERR_GCM_HW_ACCEL_FAILED</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_ERR_GCM_HW_ACCEL_FAILED                  -19 /**< GCM hardware accelerator failed. */
</code></pre>
      <pre class="doc-comment">/* MBEDTLS_ERR_GCM_HW_ACCEL_FAILED is deprecated and should not be used. */</pre>

      <h4 id="MBEDTLS_ERR_GCM_BAD_INPUT">Marco <span>MBEDTLS_ERR_GCM_BAD_INPUT</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_ERR_GCM_BAD_INPUT                        -20 /**< Bad input parameters to function. */
</code></pre>
      <pre class="doc-comment"></pre>
      <h3 id="functions">Functions</h3>
      

      <h4 id="mbedtls_gcm_init">Func <span>mbedtls_gcm_init</span></h4>
      <pre class="doc-declare"><code>void mbedtls_gcm_init( mbedtls_gcm_context *ctx );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function initializes the specified GCM context,
 *                  to make references valid, and prepares the context
 *                  for mbedtls_gcm_setkey() or mbedtls_gcm_free().
 *
 *                  The function does not bind the GCM context to a particular
 *                  cipher, nor set the key. For this purpose, use
 *                  mbedtls_gcm_setkey().
 *
 * \param ctx       The GCM context to initialize. This must not be \c NULL.
 */</pre>

      <h4 id="mbedtls_gcm_setkey">Func <span>mbedtls_gcm_setkey</span></h4>
      <pre class="doc-declare"><code>int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx,
                       mbedtls_cipher_id_t cipher,
                       const unsigned char *key,
                       unsigned int keybits );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function associates a GCM context with a
 *                  cipher algorithm and a key.
 *
 * \param ctx       The GCM context. This must be initialized.
 * \param cipher    The 128-bit block cipher to use.
 * \param key       The encryption key. This must be a readable buffer of at
 *                  least \p keybits bits.
 * \param keybits   The key size in bits. Valid options are:
 *                  <ul><li>128 bits</li>
 *                  <li>192 bits</li>
 *                  <li>256 bits</li></ul>
 *
 * \return          \c 0 on success.
 * \return          A cipher-specific error code on failure.
 */</pre>

      <h4 id="mbedtls_gcm_crypt_and_tag">Func <span>mbedtls_gcm_crypt_and_tag</span></h4>
      <pre class="doc-declare"><code>int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx,
                      int mode,
                      size_t length,
                      const unsigned char *iv,
                      size_t iv_len,
                      const unsigned char *add,
                      size_t add_len,
                      const unsigned char *input,
                      unsigned char *output,
                      size_t tag_len,
                      unsigned char *tag );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function performs GCM encryption or decryption of a buffer.
 *
 * \note            For encryption, the output buffer can be the same as the
 *                  input buffer. For decryption, the output buffer cannot be
 *                  the same as input buffer. If the buffers overlap, the output
 *                  buffer must trail at least 8 Bytes behind the input buffer.
 *
 * \warning         When this function performs a decryption, it outputs the
 *                  authentication tag and does not verify that the data is
 *                  authentic. You should use this function to perform encryption
 *                  only. For decryption, use mbedtls_gcm_auth_decrypt() instead.
 *
 * \param ctx       The GCM context to use for encryption or decryption. This
 *                  must be initialized.
 * \param mode      The operation to perform:
 *                  - #MBEDTLS_GCM_ENCRYPT to perform authenticated encryption.
 *                    The ciphertext is written to \p output and the
 *                    authentication tag is written to \p tag.
 *                  - #MBEDTLS_GCM_DECRYPT to perform decryption.
 *                    The plaintext is written to \p output and the
 *                    authentication tag is written to \p tag.
 *                    Note that this mode is not recommended, because it does
 *                    not verify the authenticity of the data. For this reason,
 *                    you should use mbedtls_gcm_auth_decrypt() instead of
 *                    calling this function in decryption mode.
 * \param length    The length of the input data, which is equal to the length
 *                  of the output data.
 * \param iv        The initialization vector. This must be a readable buffer of
 *                  at least \p iv_len Bytes.
 * \param iv_len    The length of the IV.
 * \param add       The buffer holding the additional data. This must be of at
 *                  least that size in Bytes.
 * \param add_len   The length of the additional data.
 * \param input     The buffer holding the input data. If \p length is greater
 *                  than zero, this must be a readable buffer of at least that
 *                  size in Bytes.
 * \param output    The buffer for holding the output data. If \p length is greater
 *                  than zero, this must be a writable buffer of at least that
 *                  size in Bytes.
 * \param tag_len   The length of the tag to generate.
 * \param tag       The buffer for holding the tag. This must be a readable
 *                  buffer of at least \p tag_len Bytes.
 *
 * \return          \c 0 if the encryption or decryption was performed
 *                  successfully. Note that in #MBEDTLS_GCM_DECRYPT mode,
 *                  this does not indicate that the data is authentic.
 * \return          #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths or pointers are
 *                  not valid or a cipher-specific error code if the encryption
 *                  or decryption failed.
 */</pre>

      <h4 id="mbedtls_gcm_auth_decrypt">Func <span>mbedtls_gcm_auth_decrypt</span></h4>
      <pre class="doc-declare"><code>int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx,
                     size_t length,
                     const unsigned char *iv,
                     size_t iv_len,
                     const unsigned char *add,
                     size_t add_len,
                     const unsigned char *tag,
                     size_t tag_len,
                     const unsigned char *input,
                     unsigned char *output );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function performs a GCM authenticated decryption of a
 *                  buffer.
 *
 * \note            For decryption, the output buffer cannot be the same as
 *                  input buffer. If the buffers overlap, the output buffer
 *                  must trail at least 8 Bytes behind the input buffer.
 *
 * \param ctx       The GCM context. This must be initialized.
 * \param length    The length of the ciphertext to decrypt, which is also
 *                  the length of the decrypted plaintext.
 * \param iv        The initialization vector. This must be a readable buffer
 *                  of at least \p iv_len Bytes.
 * \param iv_len    The length of the IV.
 * \param add       The buffer holding the additional data. This must be of at
 *                  least that size in Bytes.
 * \param add_len   The length of the additional data.
 * \param tag       The buffer holding the tag to verify. This must be a
 *                  readable buffer of at least \p tag_len Bytes.
 * \param tag_len   The length of the tag to verify.
 * \param input     The buffer holding the ciphertext. If \p length is greater
 *                  than zero, this must be a readable buffer of at least that
 *                  size.
 * \param output    The buffer for holding the decrypted plaintext. If \p length
 *                  is greater than zero, this must be a writable buffer of at
 *                  least that size.
 *
 * \return          \c 0 if successful and authenticated.
 * \return          #MBEDTLS_ERR_GCM_AUTH_FAILED if the tag does not match.
 * \return          #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths or pointers are
 *                  not valid or a cipher-specific error code if the decryption
 *                  failed.
 */</pre>

      <h4 id="mbedtls_gcm_starts">Func <span>mbedtls_gcm_starts</span></h4>
      <pre class="doc-declare"><code>int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
               int mode,
               const unsigned char *iv,
               size_t iv_len,
               const unsigned char *add,
               size_t add_len );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function starts a GCM encryption or decryption
 *                  operation.
 *
 * \param ctx       The GCM context. This must be initialized.
 * \param mode      The operation to perform: #MBEDTLS_GCM_ENCRYPT or
 *                  #MBEDTLS_GCM_DECRYPT.
 * \param iv        The initialization vector. This must be a readable buffer of
 *                  at least \p iv_len Bytes.
 * \param iv_len    The length of the IV.
 * \param add       The buffer holding the additional data, or \c NULL
 *                  if \p add_len is \c 0.
 * \param add_len   The length of the additional data. If \c 0,
 *                  \p add may be \c NULL.
 *
 * \return          \c 0 on success.
 */</pre>

      <h4 id="mbedtls_gcm_update">Func <span>mbedtls_gcm_update</span></h4>
      <pre class="doc-declare"><code>int mbedtls_gcm_update( mbedtls_gcm_context *ctx,
               size_t length,
               const unsigned char *input,
               unsigned char *output );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function feeds an input buffer into an ongoing GCM
 *                  encryption or decryption operation.
 *
 *    `             The function expects input to be a multiple of 16
 *                  Bytes. Only the last call before calling
 *                  mbedtls_gcm_finish() can be less than 16 Bytes.
 *
 * \note            For decryption, the output buffer cannot be the same as
 *                  input buffer. If the buffers overlap, the output buffer
 *                  must trail at least 8 Bytes behind the input buffer.
 *
 * \param ctx       The GCM context. This must be initialized.
 * \param length    The length of the input data. This must be a multiple of
 *                  16 except in the last call before mbedtls_gcm_finish().
 * \param input     The buffer holding the input data. If \p length is greater
 *                  than zero, this must be a readable buffer of at least that
 *                  size in Bytes.
 * \param output    The buffer for holding the output data. If \p length is
 *                  greater than zero, this must be a writable buffer of at
 *                  least that size in Bytes.
 *
 * \return         \c 0 on success.
 * \return         #MBEDTLS_ERR_GCM_BAD_INPUT on failure.
 */</pre>

      <h4 id="mbedtls_gcm_finish">Func <span>mbedtls_gcm_finish</span></h4>
      <pre class="doc-declare"><code>int mbedtls_gcm_finish( mbedtls_gcm_context *ctx,
               unsigned char *tag,
               size_t tag_len );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function finishes the GCM operation and generates
 *                  the authentication tag.
 *
 *                  It wraps up the GCM stream, and generates the
 *                  tag. The tag can have a maximum length of 16 Bytes.
 *
 * \param ctx       The GCM context. This must be initialized.
 * \param tag       The buffer for holding the tag. This must be a readable
 *                  buffer of at least \p tag_len Bytes.
 * \param tag_len   The length of the tag to generate. This must be at least
 *                  four.
 *
 * \return          \c 0 on success.
 * \return          #MBEDTLS_ERR_GCM_BAD_INPUT on failure.
 */</pre>

      <h4 id="mbedtls_gcm_free">Func <span>mbedtls_gcm_free</span></h4>
      <pre class="doc-declare"><code>void mbedtls_gcm_free( mbedtls_gcm_context *ctx );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function clears a GCM context and the underlying
 *                  cipher sub-context.
 *
 * \param ctx       The GCM context to clear. If this is \c NULL, the call has
 *                  no effect. Otherwise, this must be initialized.
 */</pre>

      <h4 id="mbedtls_gcm_self_test">Func <span>mbedtls_gcm_self_test</span></h4>
      <pre class="doc-declare"><code>int mbedtls_gcm_self_test( int verbose );</code></pre>
      <pre class="doc-comment">/**
 * \brief          The GCM checkup routine.
 *
 * \return         \c 0 on success.
 * \return         \c 1 on failure.
 */</pre>
      <h3 id="vars">Vars</h3>
      
      <h3 id="consts">Consts</h3>
      
      <h3 id="types">Types</h3>
      
      <h3 id="typedefs">Typedefs</h3>
      

      <h4 id="
mbedtls_gcm_context;
">Typedef <span>
mbedtls_gcm_context;
</span></h4>
      <pre class="doc-declare"><code>typedef struct mbedtls_gcm_context
{
   mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */
   uint64_t HL[16];                     /*!< Precalculated HTable low. */
   uint64_t HH[16];                     /*!< Precalculated HTable high. */
   uint64_t len;                        /*!< The total length of the encrypted data. */
   uint64_t add_len;                    /*!< The total length of the additional data. */
   unsigned char base_ectr[16];         /*!< The first ECTR for tag. */
   unsigned char y[16];                 /*!< The Y working value. */
   unsigned char buf[16];               /*!< The buf working value. */
   int mode;                            /*!< The operation to perform:
                                               #MBEDTLS_GCM_ENCRYPT or
                                               #MBEDTLS_GCM_DECRYPT. */
}
mbedtls_gcm_context;
</code></pre>
      <pre class="doc-comment">/**
 * \brief          The GCM context structure.
 */</pre>
    </div>
  </body>
</html>
            